/*** Eclipse Class Decompiler plugin, copyright (c) 2012 Chao Chen (cnfree2000@hotmail.com) ***/
package com.qihoopp.qcoinpay;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.res.Configuration;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.KeyEvent;
import android.view.View;
import android.view.Window;
import android.widget.FrameLayout.LayoutParams;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.Toast;
import com.qihoopp.framework.HttpCreater;
import com.qihoopp.framework.HttpLoadThread;
import com.qihoopp.framework.HttpLoaderCallback;
import com.qihoopp.framework.HttpRequestMode;
import com.qihoopp.framework.LogUtil;
import com.qihoopp.framework.MD5;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;

public class QcoinActivity extends Activity implements n {
    private aq a;
    private aw b;
    private Activity c;
    private Intent d;
    private bc e;
    private t f;
    private bi g;
    private String h;
    private ArrayList i;
    private u j;
    private ae k;
    private ae l;
    private ListView m;
    private ae n;
    private ag o;
    private HttpLoaderCallback p = new au(this);
    private int q = -1;
    private m r;
    private boolean s = false;
    private HttpLoaderCallback t = new bf(this);
    private HttpLoaderCallback u = new bh(this);

    protected void onCreate(Bundle paramBundle) {
        super.onCreate(paramBundle);
        this.c = this;
        this.d = getIntent();
        requestWindowFeature(1);
        cy.d(this.c);
        cy.c(this.c);
        LogUtil.d("QcoinActivity", "Resolution: " + cy.b(this.c) + "*" + cy.a(this.c));
        if (!(TextUtils.isEmpty(paramBundle = this.d.getExtras().getString("basefolder_load")))) {
            if (!(paramBundle.endsWith(File.separator)))
                paramBundle = paramBundle + File.separator;
            cx.b = paramBundle;
        }
        LogUtil.d("QcoinActivity", "onCreate() --> res dir = " + cx.b);
        paramBundle = this.d.getStringExtra("token");
        Object localObject = this.d.getStringExtra("seckey");
        this.f = new t(paramBundle, (String) localObject);
        this.g = bi.a(this.c);
        this.c.getWindow().setBackgroundDrawable(new ColorDrawable(-986896));
        this.i = new ArrayList();
        this.e = new bc(this.c, this.f, this);
        this.c.setContentView(this.e.f);
        HttpLoaderCallback localHttpLoaderCallback = this.p;
        t localt = this.f;
        localObject = this.c;
        paramBundle = this;
        LinkedHashMap localLinkedHashMap = new LinkedHashMap();
        String str1 = System.currentTimeMillis();
        String str2 = MD5.getMD5("token=" + localt.a + "&ts=" + str1 + localt.b);
        localLinkedHashMap.put("token", localt.a);
        localLinkedHashMap.put("ts", str1);
        localLinkedHashMap.put("sign", str2);
        localObject = new HttpCreater().create((Context) localObject, HttpRequestMode.POST,
                "https://api.360pay.cn/securePay/getOrder", localLinkedHashMap, null, localHttpLoaderCallback);
        paramBundle.i.add(localObject);
        ((HttpLoadThread) localObject).start();
        this.s = false;
    }

    public void onDestroy() {
        super.onDestroy();
        LogUtil.d("QcoinActivity", "onDestroyControl");
        Object localObject = this.i.iterator();
        while (((Iterator) localObject).hasNext()) {
            HttpLoadThread localHttpLoadThread = (HttpLoadThread) ((Iterator) localObject).next();
            LogUtil.d("QcoinActivity",
                    "task" + localHttpLoadThread.getId() + "   alive = " + localHttpLoadThread.isAlive());
            if (localHttpLoadThread.isAlive())
                localHttpLoadThread.cancel();
        }
        this.i.clear();
        if ((localObject = bi.b).b != null) {
            ((o) localObject).b.a(-1);
            LogUtil.d("ImageCache", "Memory cache cleared");
        }
        bi.c = null;
        bi.a = null;
        bi.b = null;
        Runtime.getRuntime().gc();
        LogUtil.e("QcoinActivity", "attemp to gc");
    }

    protected void finalize() {
        super.finalize();
        LogUtil.e("QcoinActivity", "finalize");
    }

    public boolean onKeyDown(int paramInt, KeyEvent paramKeyEvent) {
        LogUtil.d("QcoinActivity", "Key Down!, keyCode = " + paramInt);
        if (4 == paramInt) {
            if ((this.o != null) && (this.o.isShown()))
                return true;
            if ((this.a != null) && (this.a.b() != null) && (this.a.b().isShown())) {
                this.a.a();
                return true;
            }
            if ((this.b != null) && (this.b.d() != null) && (this.b.d().isShown())) {
                this.b.c();
                return true;
            }
            if ((this.l != null) && (this.l.isShown()))
                return true;
            if ((this.k != null) && (this.k.isShown())) {
                this.e.a();
                return true;
            }
            if ((this.m != null) && (this.m.isShown())) {
                this.e.a();
                return true;
            }
            if ((this.n != null) && (this.n.isShown())) {
                this.e.a();
                return true;
            }
            if ((this.e != null) && (this.e.e != null) && (this.e.e.isShown())) {
                a();
                return true;
            }
            if (this.e != null) {
                bc localbc;
                if (((((localbc = this.e).g != null) && (localbc.g.b.isShown())) ? 1 : 0) != 0)
                    this.c.setResult(100);
            }
        }
        return super.onKeyDown(paramInt, paramKeyEvent);
    }

    public void onConfigurationChanged(Configuration paramConfiguration) {
        super.onConfigurationChanged(paramConfiguration);
        if (!("MOBILE_QCOIN".equals(this.e.d.f)))
            return;
        this.e.d.g.a();
        this.e.d.g.a(paramConfiguration);
    }

    public final void a(String paramString) {
        a(paramString, true);
    }

    public final void a(String paramString, boolean paramBoolean) {
        if (this.l == null)
            this.l = new ae(this.c, "img_error.png", a.a(b.n), "");
        this.l.b(paramString);
        this.l.a(a.a(b.u));
        paramString = new az(this, paramBoolean);
        this.l.a(paramString);
        this.l.c(paramString);
        this.e.a(this.l, true);
    }

    private void b() {
        if (this.o == null)
            this.o = new ag(this.c);
        this.e.a(this.o, true);
    }

    public final void a(String paramString1, String paramString2, View paramView) {
        if (!("MOBILE_QCOIN".equals(paramString1)))
            return;
        this.a = new aq(this.c, paramString2, this);
        this.a.b().setLayoutParams(new FrameLayout.LayoutParams(-1, -1));
        this.e.a(this.a.b());
        paramView.setEnabled(true);
    }

    public final void a(View paramView, String paramString1, String paramString2) {
        if (!("MOBILE_QCOIN".equals(paramString1)))
            return;
        cz.a(this.c);
        paramView = new v(this.c, new ba(this, paramView));
        b();
        paramView = paramView.a(paramString2, this.f.a, this.f.b);
        this.i.add(paramView);
        paramView.start();
    }

    public final void a() {
        if (this.n == null) {
            this.n = new ae(this.c, "img_error.png", a.a(b.n), a.a(b.o));
            this.n.b(a.a(b.q));
            bb localbb = new bb(this);
            this.n.b(localbb);
            this.n.c(localbb);
            this.n.a(new bd(this));
        }
        this.e.a(this.n, false);
    }

    public final void a(String paramString1, String paramString2, String paramString3, String paramString4) {
        cz.a(this.c);
        b();
        LinkedHashMap localLinkedHashMap = new LinkedHashMap();
        String str1 = System.currentTimeMillis();
        String str2 = "";
        String str3 = "";
        String str4 = "";
        String str5 = "";
        try {
            cv localcv = new cv(this.f.b.substring(0, 16), this.f.b.substring(16, this.f.b.length()),
                    "AES/CBC/PKCS5Padding");
            paramString1 = null;
            str2 = cw.a(localcv.a(dc.a(paramString1)));
            paramString1 = localcv.a(dc.a("360pay360" + paramString2));
            str3 = cw.a(localcv.a(dc.a(paramString2)));
            str4 = cw.a(paramString1);
            str5 = cw.a(localcv.a(dc.a("360pay360" + paramString4)));
        } catch (Exception localException) {
            LogUtil.e("QcoinActivity", "Execption", localException);
        }
        localLinkedHashMap.put("answer", str5);
        localLinkedHashMap.put("loginpwd", str2);
        localLinkedHashMap.put("paypwd", str4);
        localLinkedHashMap.put("paypwdo", str3);
        localLinkedHashMap.put("question", paramString3);
        localLinkedHashMap.put("token", this.f.a);
        localLinkedHashMap.put("ts", str1);
        String str6 = cz.a(localLinkedHashMap, this.f.b);
        localLinkedHashMap.put("sign", str6);
        new HttpCreater().create(this.c, HttpRequestMode.POST, "https://api.360pay.cn/securePay/initQidPaypwd",
                localLinkedHashMap, null, new be(this, paramString3)).start();
    }

    public final void b(String paramString) {
        cz.a(this.c);
        if (paramString.equals(aq.class.getName())) {
            this.e.b();
            return;
        }
        if (!(paramString.equals(aw.class.getName())))
            return;
        this.e.b();
        if (TextUtils.isEmpty(this.j.m))
            return;
        paramString = this;
        LogUtil.d("QcoinActivity", "enter myUnRegisterBroadcast()");
        if ((paramString.r == null) || (!(paramString.s)))
            return;
        try {
            paramString.unregisterReceiver(paramString.r);
            paramString.r = null;
            paramString.s = false;
            LogUtil.e("QcoinActivity", "unregister MessageReceivedManager success.");
            return;
        } catch (Exception localException) {
            LogUtil.e("QcoinActivity", "unregister MessageReceivedManager failed.");
        }
    }

    public final void a(String paramString1, String paramString2, String paramString3) {
        if (TextUtils.isEmpty(paramString1))
            paramString1 = paramString2;
        if (paramString1.equals("2")) {
            a(paramString3, false);
            return;
        }
        if (paramString1.equals("3")) {
            a(paramString3, true);
            return;
        }
        if (!(paramString1.equals("1")))
            return;
        Toast.makeText(this, paramString3, 0).show();
    }

    public final void a(String paramString1, String paramString2, String paramString3, String paramString4,
            String paramString5, View paramView) {
        if (!("MOBILE_QCOIN_RESET".equals(paramString1)))
            return;
        if (this.b == null) {
            this.b = new aw(this.c, paramString2, paramString3, paramString4, paramString5, this);
            this.b.d().setLayoutParams(new FrameLayout.LayoutParams(-1, -1));
        }
        this.e.a(this.b.d());
        if (!(TextUtils.isEmpty(paramString3))) {
            LogUtil.e("QcoinActivity", "showNewWindow user_bindphone is not empty.");
            paramString1 = this;
            LogUtil.d("QcoinActivity", "enter myRegitsterBroadcast()");
            if (paramString1.r == null)
                try {
                    paramString1.r = new m(paramString1);
                } catch (Exception localException1) {
                    LogUtil.e("QcoinActivity", "new MessageReceivedManager failed.");
                }
            if ((paramString1.r != null) && (!(paramString1.s)))
                try {
                    paramString1.registerReceiver(paramString1.r, new IntentFilter(
                            "android.provider.Telephony.SMS_RECEIVED"));
                    paramString1.s = true;
                    LogUtil.e("QcoinActivity", "register MessageReceivedManager success.");
                } catch (Exception localException2) {
                    LogUtil.e("QcoinActivity", "register MessageReceivedManager failed.");
                }
        }
        paramView.setEnabled(true);
    }

    public final void a(String paramString1, String paramString2) {
        if (!("MOBILE_QCOIN_RESET".equals(paramString1)))
            return;
        if (this.b != null)
            this.b.g();
        String str2 = this.f.b;
        String str1 = this.f.a;
        y localy = y.e;
        paramString2 = paramString2;
        paramString1 = new x(this, this.u);
        HashMap localHashMap = new HashMap();
        LogUtil.e(paramString1.d, "requstSendSMSCode, enter request.");
        if (TextUtils.isEmpty(paramString2))
            LogUtil.e(paramString1.d, "requstSendSMSCode, phone is empty!");
        localHashMap.put("token", str1);
        localHashMap.put("phone", paramString2);
        if (localy == y.a)
            paramString1.c = "pay";
        else if (localy == y.b)
            paramString1.c = "user_bindphone";
        else if (localy == y.c)
            paramString1.c = "avoid_smscode_amt";
        else if (localy == y.d)
            paramString1.c = "set_qcoin_paypwd";
        else if (localy == y.e)
            paramString1.c = "reset_qcoin_paypwd";
        else
            LogUtil.e(paramString1.d, "reqestSendSMSCode, sendmode not defined!");
        localHashMap.put("service", paramString1.c);
        paramString2 = System.currentTimeMillis();
        localHashMap.put("ts", paramString2);
        paramString2 = cx.a;
        localHashMap.put("version", paramString2);
        paramString2 = cz.a(localHashMap, str2);
        localHashMap.put("sign", paramString2);
        new HttpCreater().create(paramString1.a, HttpRequestMode.POST, "https://api.360pay.cn/securePay/sendSMSCode",
                localHashMap, null, paramString1.b).start();
    }

    public final void b(String paramString1, String paramString2) {
        w localw = new w(this, this.t);
        b();
        paramString1 = localw.a(paramString2, paramString1, this.f.a, this.f.b);
        this.i.add(paramString1);
        paramString1.start();
    }

    public final void b(String paramString1, String paramString2, String paramString3) {
        w localw = new w(this, this.t);
        b();
        paramString1 = localw.a(paramString1, paramString2, paramString3, this.f.a, this.f.b);
        this.i.add(paramString1);
        paramString1.start();
    }
}